<!DOCTYPE html>
<html>
<head>
    <title>我的游记</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/css/dialog.css"/>
    <script src="/js/plugins/dialog2/js/dialog.min.js"></script>

</head>

<script>
    $(function () {
        var page=$('#currentPage');
        var pages ;
        var travelArr = [];
        var user = JSON.parse(sessionStorage.getItem("user"));
        function send() {
            $.get("/users/"+user.id+"/travels",{currentPage:page.val()},function (data) {
                console.log(data);
                $.merge(travelArr,data.list);
                $('.travels').renderValues({list:travelArr},{
                    getHref:function (item, value) {
                        var href = $(item).data('href');
                        $(item).attr('href',href+value);
                    }

                });

                page.val(parseInt(page.val())+1);
                pages = data.pages;
            });
        }
        send();
        $(window).scroll(function () {
            if ($(document).scrollTop()+$(window).height()>=$(document).height()){
                if (page.val() <= pages){
                    send();
                }else {
                    $(document).dialog({
                        type : 'notice',
                        infoText: '已经到底啦！',
                        autoClose: 1500,
                        position: 'bottom'  // center: 居中; bottom: 底部
                    });
                }
            }
        });



    });
</script>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="profiles.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的游记</span>
        </div>
        <div class="col"></div>
    </div>
</div>
<input type="hidden" name="currentPage" id="currentPage" value="1">

<div class="container travels">
    <dl class="list" render-loop="list">
        <dd>
            <input  type="hidden" name="id"  class="getId" render-value="list.id"/>
            <a data-href="editTravels.html?id=" render-key="list.id" render-fun="getHref">
                <img render-src="list.coverUrl">
                <h6 class="title" render-html="list.title"></h6>
                <p>最近更新时间 <span render-html="list.lastUpdateTime"></span>
                    <span class="span-right">
							  <i class="fa fa-heart"></i><span id="b"></span>收藏
						  <i class="fa fa-thumbs-o-up"></i><span id="a"></span>点赞</span>
                </p>
            </a>
        </dd>
    </dl>
</div>


</body>

</html>

